<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作元素的样式</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            height: 200px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div id="box" style="width: 200px; color: black;background-color: yellow">123456</div>
    <script>
        //内部样式
        console.log(box.style.width) 
        console.log(box.style["background-color"]) 
        console.log(box.style.backgroundColor) 
        box.style.width = "300px"
        box.style.backgroundColor = "red"

        console.log(window.getComputedStyle(box).backgroundColor)
        console.log(window.getComputedStyle(box)["color"])
    </script>
</body>
</html>